History for Statement Blocks and Conditionals
??changed:
-
This is a place where DTML really breaks down IMHO. Not to mention the
fact that the rendered HTML code is usually nearly unreadable if you
indent the DTML in a readable way. This is a nitpick surely, but a
fixable problem. Maybe I'm just anal retentive...
I feel that C and other languages are a good model here. C compliers
generally have a preprocessor that scans the code looking
for conditionals and defines and deals with them. This basically what
Zope is doing, preprocessing the DTML code to spit out HTML code for the
browser to render.
So, in keeping with this idea I propose that all block level statements
begin with a pound sign (#). Furthermore, they will follow the Python
rules of indentation, thus eliminating the need for block end tags such
as </dtml-if> and the like. Zope will also strip this block denoting
indentation while rendering so that the resulting HTML will look decent.
A built in method ^t could be used to insert literal tabs into the HTML
output without upsetting the block structure. The use of these would of
course be optional.
Example
<pre>
#for image in images.objectValues():
<tr>
^t;<td>^image
</pre>
The resulting HTML would look something like this:
<pre>
<tr>
<td><IMG SRC="http://server/folder/image1" width="100" height="75">
<tr>
<td><IMG SRC="http://server/folder/image2" width="100" height="75">
...
</pre>
Another gripe I have with DTML is that the if statement not only tests for
truth, but also for existence (like an ifdef conditional). This can make
it's behavior somewhat unintuitive at times at least to me. I say there
shall be an <tt>if</tt> statement and a separate <tt>if-exists</tt>
statement
<pre>
#if-exists AUTHENTICATED_USER:
<H2>Welcome to Foobar Central!</H2>
<P>^AUTHENTICATED_USER;, your fortune is: ^fortune
#else
!raise(type="Forbidden", message="Get Lost!")
</pre>
*More to come...*